//
//  TeacherViewController.m
//  WheatPlan
//
//  Created by 王晨辉 on 15/5/27.
//  Copyright (c) 2015年 IOSTeam. All rights reserved.
//

#import "TeacherViewController.h"
#import "AppointmentViewController.h"
#import "IndividualViewController.h"

@interface TeacherViewController ()

@end

@implementation TeacherViewController


-(void)viewWillAppear:(BOOL)animated{
    
    
    
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
//    [GetFileModel ShowProgressHUDwithMessage:@"耐心等待"];

    
    //设置导航栏头文字
    self.navigationItem.title = @"老师介绍";
    //设置导航栏背景颜色
    [self.navigationController.navigationBar setBarTintColor:[GetFileModel colorWithHexString:@"#ef5858" alpha:1]];
    //设置导航栏字体颜色
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName,nil]];
    //左边按钮
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:@"_0000_返回.png"]
                      forState:UIControlStateNormal];
    [button addTarget:self action:@selector(back)
     forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(0, 0, 20, 15);
    
    
    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    self.navigationItem.leftBarButtonItem = menuButton;

    [self subView];
    
}
-(void)subView{
    
    
    _makeLabel = [[UILabel alloc]init];
    _makeLabel.frame = CGRectMake(0, NavbarHight, SCREEN_WIDTH, SCREEN_WIDTH/3.7);
    _makeLabel.text = @"早教指导师介绍";
    _makeLabel.font = [UIFont systemFontOfSize:20];
    _makeLabel.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:_makeLabel];
    
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, NavbarHight-20+SCREEN_WIDTH/3.7, SCREEN_WIDTH, 1)];
    lineView.backgroundColor = UIColorWithRGBA(215, 215, 215, 1);
    [self.view addSubview:lineView];
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString *ID = [user objectForKey:@"ID"];


    ////NSLog(@"%@",self.identify);

    NSDictionary *param2 = @{@"userId":ID,@"identify": self.identify,@"ealyType":@"4",/*@"babyId":[BabyManager shareInstance].babyId,*/};
    [UserDAL getTowPreschoolEducationInfoParams:param2 withBlock:^(NSDictionary *data, NSError *error) {
        if (data) {
            
            
            ////NSLog(@"%@321123",data);
            if (data.count!=0) {
                
                
            NSString * str = [data objectForKey:@"msg"];
            ////NSLog(@"%@",str);

                
            UILabel * testlable = [[UILabel alloc]initWithFrame:CGRectMake(10,20,200,20)];
            
            NSString * tstring = [data objectForKey:@"brief"];
            
            ////NSLog(@"%@",tstring);
            
            
            testlable.numberOfLines =0;
            
            UIFont * tfont = [UIFont systemFontOfSize:12];
            
            testlable.font = tfont;
            
            testlable.lineBreakMode =NSLineBreakByTruncatingTail ;
            
            testlable.text = tstring ;
            [testlable setBackgroundColor:[UIColor whiteColor]];
            
            [self.view addSubview:testlable];
            
            
            CGSize size =CGSizeMake(SCREEN_WIDTH-20,MAXFLOAT);
            
            NSDictionary * tdic = [NSDictionary dictionaryWithObjectsAndKeys:tfont,NSFontAttributeName,nil];
            CGSize  actualsize =[tstring boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin  attributes:tdic context:nil].size;
            
            
            
            testlable.frame =CGRectMake(10,NavbarHight-20+SCREEN_WIDTH/3.7+20, actualsize.width, actualsize.height);
            
            [self.view addSubview:testlable];
            
            
            
            
            }else{
                
                
                alert(@"暂无老师信息");
                
                
            }
            
        }else
        {
            
        }
    }];
    
    
    UIButton * but = [UIButton buttonWithType:1];
    but.frame = CGRectMake(70, SCREEN_HEIGHT-70, SCREEN_WIDTH-140, 40);
    [but setBackgroundImage:[UIImage imageNamed:@"确认预约-点击后@2x.png.png"] forState:UIControlStateNormal];
    [but addTarget:self action:@selector(btnClick) forControlEvents:UIControlEventTouchUpInside];
    
    if ([self.type integerValue] == 1) {
        [self.view addSubview:but];

    }else{
        
        [but removeFromSuperview];

        
    }
    
}
-(void)btnClick{
    
    ////NSLog(@"11123123123");
    IndividualViewController * indiviController = [[IndividualViewController alloc]init];
    indiviController.identifya = self.identify;
    indiviController.name = self.nameTea;
    indiviController.otherStr = self.brief;
    indiviController.manei = self.manei;
    indiviController.pic = self.pic;

    UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:indiviController];
    [self presentViewController:nav animated:YES completion:nil];
    
    
    
    
    
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

{
    
    
    NSString *msg = [[NSString alloc] initWithFormat:@"您点击的是第%d个按钮!",buttonIndex];
    ////NSLog(@"msg:%@",msg);
    if (buttonIndex == 0) {
        
        [self dismissViewControllerAnimated:YES completion:nil];
        ////NSLog(@"1111111");
        
    }else if(buttonIndex == 1){
        
        
        ////NSLog(@"2222222");
        
        
    }
    
    
}




-(void)back{
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
}
-(void)baby{
    	
    [self dismissViewControllerAnimated:YES completion:nil];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
